package com.elaticsearch.test;

import org.apache.http.HttpHost;
import org.elasticsearch.client.IndicesClient;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import org.elasticsearch.cluster.metadata.AliasMetadata;

import java.util.List;
import java.util.Map;

/**
 * @author:左泽林
 * @date:日期:2021-08-28-时间:11:21
 * @message:
 */
public class Search {
    public static void main(String[] args) {
        //创建ES客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("172.20.17.43",9200,"http"))
        );

        //关闭ES客户端
        try {
            GetIndexRequest user = new GetIndexRequest("dex");
            GetIndexResponse getIndexResponse = esClient.indices().get(user, RequestOptions.DEFAULT);

            //响应状态
            System.out.println(getIndexResponse.getAliases());
            System.out.println(getIndexResponse.getMappings());
            System.out.println(getIndexResponse.getSettings());

            esClient.close();
        }catch (Exception e){
            System.out.println(e);
        }
    }
}
